<!DOCTYPE html>
<html lang=zh>
<head>
    <meta charset="utf-8">
    
    <title>Android源码下载-Windows | Kuper&#39;s Blog</title>
    
    
        <meta name="keywords" content="Android" />
    
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="安装Python 官网地址 我下载的是3.6.3的版本 安装GIT 官网地址 下载最新版本即可 克隆主仓库，查看源码版本分支 找一个容量大的硬盘分区，至少有120G可用空间，克隆仓库。假如你要编译源代码的话，需要更大的空间准备160G以上吧。123456789C:\Users\shenchunping&gt;cd E:\C:\Users\shenchunping&gt;E:E:\&gt;mkdir">
<meta property="og:type" content="article">
<meta property="og:title" content="Android源码下载-Windows">
<meta property="og:url" content="https://shenchunping.github.io/2018/08/06/Android%E6%BA%90%E7%A0%81%E4%B8%8B%E8%BD%BD-Windows/index.html">
<meta property="og:site_name" content="Kuper&#39;s Blog">
<meta property="og:description" content="安装Python 官网地址 我下载的是3.6.3的版本 安装GIT 官网地址 下载最新版本即可 克隆主仓库，查看源码版本分支 找一个容量大的硬盘分区，至少有120G可用空间，克隆仓库。假如你要编译源代码的话，需要更大的空间准备160G以上吧。123456789C:\Users\shenchunping&gt;cd E:\C:\Users\shenchunping&gt;E:E:\&gt;mkdir">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/2093886-2a293e366bdcba76.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/2093886-dcbfb890c573a27f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/2093886-a856b025d87fedac.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/2093886-9aee698760fe6da6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="article:published_time" content="2018-08-05T16:00:00.000Z">
<meta property="article:modified_time" content="2020-05-25T05:56:45.047Z">
<meta property="article:author" content="沈春平">
<meta property="article:tag" content="Android">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/2093886-2a293e366bdcba76.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
    

    
        <link rel="alternate" href="/atom.xml" title="Kuper&#39;s Blog" type="application/atom+xml" />
    

    
        <link rel="icon" href="/favicon.ico" />
    

    
<link rel="stylesheet" href="/libs/font-awesome/css/font-awesome.min.css">

    
<link rel="stylesheet" href="/libs/open-sans/styles.css">

    
<link rel="stylesheet" href="/libs/source-code-pro/styles.css">


    
<link rel="stylesheet" href="/css/style.css">

    
<script src="/libs/jquery/2.1.3/jquery.min.js"></script>

    
<script src="/libs/jquery/plugins/cookie/1.4.1/jquery.cookie.js"></script>

    
    
        
<link rel="stylesheet" href="/libs/lightgallery/css/lightgallery.min.css">

    
    
        
<link rel="stylesheet" href="/libs/justified-gallery/justifiedGallery.min.css">

    
    
    
    


    
        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    
<meta name="generator" content="Hexo 4.2.1"></head>

<body>
    <div id="container">
        <header id="header">
    <div id="header-main" class="header-inner">
        <div class="outer">
            <a href="/" id="logo">
                <i class="logo"></i>
                <span class="site-title">Kuper&#39;s Blog</span>
            </a>
            <nav id="main-nav">
                
                    <a class="main-nav-link" href="/">首页</a>
                
                    <a class="main-nav-link" href="/archives">归档</a>
                
                    <a class="main-nav-link" href="/categories">分类</a>
                
                    <a class="main-nav-link" href="/tags">标签</a>
                
                    <a class="main-nav-link" href="/about">关于</a>
                
            </nav>
            
            <div id="search-form-wrap">

    <form class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="搜索" />
        <button type="submit" class="search-form-submit"></button>
    </form>
    <div class="ins-search">
    <div class="ins-search-mask"></div>
    <div class="ins-search-container">
        <div class="ins-input-wrapper">
            <input type="text" class="ins-search-input" placeholder="想要查找什么..." />
            <span class="ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(未命名)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>

<script src="/js/insight.js"></script>


</div>
        </div>
    </div>
    <div id="main-nav-mobile" class="header-sub header-inner">
        <table class="menu outer">
            <tr>
                
                    <td><a class="main-nav-link" href="/">首页</a></td>
                
                    <td><a class="main-nav-link" href="/archives">归档</a></td>
                
                    <td><a class="main-nav-link" href="/categories">分类</a></td>
                
                    <td><a class="main-nav-link" href="/tags">标签</a></td>
                
                    <td><a class="main-nav-link" href="/about">关于</a></td>
                
                <td>
                    
    <div class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="搜索" />
    </div>

                </td>
            </tr>
        </table>
    </div>
</header>

        <div class="outer">
            
            
                <aside id="sidebar">
   
        
    <div class="widget-wrap" id='categories'>
        <h3 class="widget-title">
            <span>分类</span>
            &nbsp;
            <a id='allExpand' href="#">
                <i class="fa fa-angle-double-down fa-2x"></i>
            </a>
        </h3>
        
        
        
         <ul class="unstyled" id="tree" > 
                    <li class="directory open">
                        <a href="#" data-role="directory">
                            <i class="fa fa-folder-open"></i>
                            &nbsp;
                            软件开发
                        </a>
                         <ul class="unstyled" id="tree" > 
                    <li class="directory">
                        <a href="#" data-role="directory">
                            <i class="fa fa-folder"></i>
                            &nbsp;
                            程序语言
                        </a>
                         <ul class="unstyled" id="tree" > 
                    <li class="directory">
                        <a href="#" data-role="directory">
                            <i class="fa fa-folder"></i>
                            &nbsp;
                            Android
                        </a>
                         <ul class="unstyled" id="tree" >  <li class="file"><a href="/2018/08/06/Android%E6%BA%90%E7%A0%81%E4%B8%8B%E8%BD%BD-Centos7/">Android源码下载-Centos7</a></li>  <li class="file"><a href="/2018/08/06/Android-ADB%E5%91%BD%E4%BB%A4%E5%AE%9E%E7%8E%B0-%E9%9A%90%E8%97%8F%E5%B9%B3%E6%9D%BF%E4%BB%BB%E5%8A%A1%E6%A0%8F/">Android-ADB命令实现-隐藏平板任务栏</a></li>  <li class="file"><a href="/2018/08/06/%E5%AE%9A%E5%88%B6%E8%AE%BE%E5%A4%87-%E6%9F%A5%E7%9C%8B%E5%B7%B2%E8%BF%9E%E6%8E%A5%E8%93%9D%E7%89%99%E8%AE%BE%E5%A4%87%E7%9A%84MAC/">定制设备-查看已连接蓝牙设备的MAC</a></li>  <li class="file"><a href="/2019/04/21/APK-%E5%8F%8D%E7%BC%96%E8%AF%91-%E5%9F%BA%E7%A1%80%E7%AF%87/">APK 反编译-基础篇</a></li>  </ul> 
                    </li> 
                    
                    <li class="directory">
                        <a href="#" data-role="directory">
                            <i class="fa fa-folder"></i>
                            &nbsp;
                            JS
                        </a>
                         <ul class="unstyled" id="tree" >  <li class="file"><a href="/2019/04/18/Cordova-%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE/">Cordova 创建项目</a></li>  </ul> 
                    </li> 
                    
                    <li class="directory">
                        <a href="#" data-role="directory">
                            <i class="fa fa-folder"></i>
                            &nbsp;
                            Java
                        </a>
                         <ul class="unstyled" id="tree" >  <li class="file"><a href="/2019/04/19/Java-%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F%E7%9B%91%E6%B5%8B%E4%B8%8E%E5%AE%9A%E4%BD%8D/">Java 内存泄漏监测与定位</a></li>  </ul> 
                    </li> 
                     </ul> 
                    </li> 
                    
                    <li class="directory open">
                        <a href="#" data-role="directory">
                            <i class="fa fa-folder-open"></i>
                            &nbsp;
                            系统与环境
                        </a>
                         <ul class="unstyled" id="tree" >  <li class="file active"><a href="/2018/08/06/Android%E6%BA%90%E7%A0%81%E4%B8%8B%E8%BD%BD-Windows/">Android源码下载-Windows</a></li>  <li class="file"><a href="/2018/08/06/Centos7-JDK%E5%AE%89%E8%A3%85%EF%BC%88SunJDK-OpenJDK%EF%BC%89/">Centos7 JDK安装（SunJDK OpenJDK）</a></li>  <li class="file"><a href="/2018/08/06/Centos7-%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8%E7%BD%91%E5%8D%A1/">Centos7-开机启动网卡</a></li>  <li class="file"><a href="/2018/08/06/Centos7-%E9%98%B2%E7%81%AB%E5%A2%99Iptables/">Centos7-防火墙Iptables</a></li>  <li class="file"><a href="/2018/08/06/Centos7-Tomcat%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/">Centos7-Tomcat安装配置</a></li>  <li class="file"><a href="/2018/08/06/Maven-%E9%85%8D%E7%BD%AE%E9%95%9C%E5%83%8F%E5%9C%B0%E5%9D%80/">Maven-配置镜像地址</a></li>  <li class="file"><a href="/2019/03/25/Ubuntu-%E5%AE%89%E8%A3%85-%E4%B8%BA%E7%9F%A5%E7%AC%94%E8%AE%B0/">Ubuntu 安装'为知笔记'</a></li>  <li class="file"><a href="/2019/03/26/key%E5%92%8Cpem%E7%94%9F%E6%88%90HTTPS%E8%AF%81%E4%B9%A6/">key和pem生成HTTPS证书</a></li>  <li class="file"><a href="/2019/04/12/Homebrew-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4-Mac/">Homebrew 常用命令-Mac</a></li>  <li class="file"><a href="/2019/04/21/%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E9%85%8D%E7%BD%AE/">环境变量配置</a></li>  </ul> 
                    </li> 
                     </ul> 
                    </li> 
                     </ul> 
    </div>
    <script>
        $(document).ready(function() {
            var iconFolderOpenClass  = 'fa-folder-open';
            var iconFolderCloseClass = 'fa-folder';
            var iconAllExpandClass = 'fa-angle-double-down';
            var iconAllPackClass = 'fa-angle-double-up';
            // Handle directory-tree expansion:
            // 左键单独展开目录
            $(document).on('click', '#categories a[data-role="directory"]', function (event) {
                event.preventDefault();

                var icon = $(this).children('.fa');
                var expanded = icon.hasClass(iconFolderOpenClass);
                var subtree = $(this).siblings('ul');
                icon.removeClass(iconFolderOpenClass).removeClass(iconFolderCloseClass);
                if (expanded) {
                    if (typeof subtree != 'undefined') {
                        subtree.slideUp({ duration: 100 });
                    }
                    icon.addClass(iconFolderCloseClass);
                } else {
                    if (typeof subtree != 'undefined') {
                        subtree.slideDown({ duration: 100 });
                    }
                    icon.addClass(iconFolderOpenClass);
                }
            });
            // 右键展开下属所有目录
            $('#categories a[data-role="directory"]').bind("contextmenu", function(event){
                event.preventDefault();
                
                var icon = $(this).children('.fa');
                var expanded = icon.hasClass(iconFolderOpenClass);
                var listNode = $(this).siblings('ul');
                var subtrees = $.merge(listNode.find('li ul'), listNode);
                var icons = $.merge(listNode.find('.fa'), icon);
                icons.removeClass(iconFolderOpenClass).removeClass(iconFolderCloseClass);
                if(expanded) {
                    subtrees.slideUp({ duration: 100 });
                    icons.addClass(iconFolderCloseClass);
                } else {
                    subtrees.slideDown({ duration: 100 });
                    icons.addClass(iconFolderOpenClass);
                }
            })
            // 展开关闭所有目录按钮
            $(document).on('click', '#allExpand', function (event) {
                event.preventDefault();
                
                var icon = $(this).children('.fa');
                var expanded = icon.hasClass(iconAllExpandClass);
                icon.removeClass(iconAllExpandClass).removeClass(iconAllPackClass);
                if(expanded) {
                    $('#sidebar .fa.fa-folder').removeClass('fa-folder').addClass('fa-folder-open')
                    $('#categories li ul').slideDown({ duration: 100 });
                    icon.addClass(iconAllPackClass);
                } else {
                    $('#sidebar .fa.fa-folder-open').removeClass('fa-folder-open').addClass('fa-folder')
                    $('#categories li ul').slideUp({ duration: 100 });
                    icon.addClass(iconAllExpandClass);
                }
            });  
        });
    </script>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title"><span>归档</span></h3>
        <div class="widget">
            <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">四月 2019</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">三月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/08/">八月 2018</a><span class="archive-list-count">9</span></li></ul>
        </div>
    </div>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title"><span>标签</span></h3>
        <div class="widget">
            <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Android/" rel="tag">Android</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CentOS/" rel="tag">CentOS</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Cordova/" rel="tag">Cordova</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/HTTPS/" rel="tag">HTTPS</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JDK/" rel="tag">JDK</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JS/" rel="tag">JS</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java/" rel="tag">Java</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Linux/" rel="tag">Linux</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Mac/" rel="tag">Mac</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Maven/" rel="tag">Maven</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Tomcat/" rel="tag">Tomcat</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Ubuntu/" rel="tag">Ubuntu</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/brew/" rel="tag">brew</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%86%85%E5%AD%98/" rel="tag">内存</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%93%9D%E7%89%99/" rel="tag">蓝牙</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%AF%81%E4%B9%A6/" rel="tag">证书</a><span class="tag-list-count">1</span></li></ul>
        </div>
    </div>

    
    <div id="toTop" class="fa fa-angle-up"></div>
</aside>
            
            <section id="main"><article id="post-Android源码下载-Windows" class="article article-type-post" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
                    <div class="article-meta">
                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/">软件开发</a><i class="fa fa-angle-right"></i><a class="article-category-link" href="/categories/%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/%E7%B3%BB%E7%BB%9F%E4%B8%8E%E7%8E%AF%E5%A2%83/">系统与环境</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/Android/" rel="tag">Android</a>
    </div>

                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2018/08/06/Android%E6%BA%90%E7%A0%81%E4%B8%8B%E8%BD%BD-Windows/">
            <time datetime="2018-08-05T16:00:00.000Z" itemprop="datePublished">2018-08-06</time>
        </a>
    </div>


                        
                            <i class="fa fa-bar-chart"></i>
                            <span id="busuanzi_container_site_pv"><span id="busuanzi_value_page_pv"></span></span>    
                        
                        
                            <div class="article-meta-button">
                                <a href='https://github.com/shenchunping/kblog/raw/master/source/_posts/Android源码下载-Windows.md' target="_blank" rel="noopener"> Source </a>
                            </div>
                            <div class="article-meta-button">
                                <a href='https://github.com/shenchunping/kblog/edit/master/source/_posts/Android源码下载-Windows.md' target="_blank" rel="noopener"> Edit </a>
                            </div>
                            <div class="article-meta-button">
                                <a href='https://github.com/shenchunping/kblog/commits/master/source/_posts/Android源码下载-Windows.md' target="_blank" rel="noopener"> History </a>
                            </div>
                        
                    </div>
                
                
    
        <h1 class="article-title" itemprop="name">
            Android源码下载-Windows
        </h1>
    

            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
        
            
                <div id="toc" class="toc-article">
                <strong class="toc-title">文章目录</strong>
                    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#安装Python"><span class="toc-number">1.</span> <span class="toc-text">安装Python</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#安装GIT"><span class="toc-number">2.</span> <span class="toc-text">安装GIT</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#克隆主仓库，查看源码版本分支"><span class="toc-number">3.</span> <span class="toc-text">克隆主仓库，查看源码版本分支</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#编辑Python下载脚本"><span class="toc-number">4.</span> <span class="toc-text">编辑Python下载脚本</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#执行Python-开始下载源码。"><span class="toc-number">5.</span> <span class="toc-text">执行Python 开始下载源码。</span></a></li></ol>
                </div>
            
        
        
            <h1 id="安装Python"><a href="#安装Python" class="headerlink" title="安装Python"></a>安装Python</h1><p> <a href="http://www.python.org/" target="_blank" rel="noopener">官网地址</a> 我下载的是3.6.3的版本</p>
<h1 id="安装GIT"><a href="#安装GIT" class="headerlink" title="安装GIT"></a>安装GIT</h1><p> <a href="https://git-scm.com/" target="_blank" rel="noopener">官网地址</a> 下载最新版本即可</p>
<h1 id="克隆主仓库，查看源码版本分支"><a href="#克隆主仓库，查看源码版本分支" class="headerlink" title="克隆主仓库，查看源码版本分支"></a>克隆主仓库，查看源码版本分支</h1><ul>
<li>找一个容量大的硬盘分区，至少有120G可用空间，克隆仓库。假如你要编译源代码的话，需要更大的空间准备160G以上吧。<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">C:\Users\shenchunping&gt;cd E:\</span><br><span class="line"></span><br><span class="line">C:\Users\shenchunping&gt;E:</span><br><span class="line"></span><br><span class="line">E:\&gt;mkdir android</span><br><span class="line"></span><br><span class="line">E:\&gt;cd android</span><br><span class="line"></span><br><span class="line">E:\android&gt;git clone https:&#x2F;&#x2F;aosp.tuna.tsinghua.edu.cn&#x2F;platform&#x2F;manifest.git</span><br></pre></td></tr></table></figure>

</li>
</ul>
<blockquote>
<p><a href="https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git" target="_blank" rel="noopener">https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git</a> 是国内镜像地址，如果不能下载可以翻墙直接通过google官方下载，直接将地址替换为  <a href="https://android.googlesource.com/platform/manifest.git" target="_blank" rel="noopener">https://android.googlesource.com/platform/manifest.git</a></p>
</blockquote>
<p>执行完成之后将在android文件夹下生成manifest文件夹，该文件夹下还没有代码。</p>
<ul>
<li><p>查看版本分支</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">E:\android&gt;cd manifest</span><br><span class="line"></span><br><span class="line">E:\android\manifest&gt;git branch -a</span><br><span class="line">* master</span><br><span class="line">  remotes&#x2F;origin&#x2F;HEAD -&gt; origin&#x2F;master</span><br><span class="line">  remotes&#x2F;origin&#x2F;adt_23.0.3</span><br><span class="line">  remotes&#x2F;origin&#x2F;afw-test-harness-1.5</span><br><span class="line">  remotes&#x2F;origin&#x2F;afw-test-harness-2.1</span><br><span class="line">  remotes&#x2F;origin&#x2F;afw-test-harness-marshmallow-dev</span><br><span class="line">  remotes&#x2F;origin&#x2F;afw-test-harness-nougat-dev</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-1.6_r1</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-1.6_r1.1</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-1.6_r1.2</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-1.6_r1.3</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-1.6_r1.4</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-1.6_r1.5</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-1.6_r2</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.0.1_r1</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.0_r1</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.1_r1</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.1_r2</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.1_r2.1p</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.1_r2.1p2</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.1_r2.1s</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.2.1_r1</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.2.1_r2</span><br><span class="line">  remotes&#x2F;origin&#x2F;android-2.2.2_r1</span><br><span class="line">...略</span><br></pre></td></tr></table></figure>
<p>最后一个“/”后面既是版本分支名称，下载我们选择一个分支下载</p>
</li>
<li><p>下载前我们注意观察manifest文件夹中的default.xml文件的default标签，大概在第六行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;default revision&#x3D;&quot;master&quot;</span><br><span class="line">          remote&#x3D;&quot;aosp&quot;</span><br><span class="line">          sync-j&#x3D;&quot;4&quot; &#x2F;&gt;</span><br></pre></td></tr></table></figure></li>
<li><p>切换到最新的版本分支,你也可以选择你想要的版本。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">E:\android\manifest&gt;git checkout android-8.1.0_r2</span><br><span class="line">Note: checking out &#39;android-8.1.0_r2&#39;.</span><br><span class="line"></span><br><span class="line">You are in &#39;detached HEAD&#39; state. You can look around, make experimental</span><br><span class="line">changes and commit them, and you can discard any commits you make in this</span><br><span class="line">state without impacting any branches by performing another checkout.</span><br><span class="line"></span><br><span class="line">If you want to create a new branch to retain commits you create, you may</span><br><span class="line">do so (now or later) by using -b with the checkout command again. Example:</span><br><span class="line"></span><br><span class="line">  git checkout -b &lt;new-branch-name&gt;</span><br><span class="line"></span><br><span class="line">HEAD is now at 85739ae... Manifest for Android 8.1.0 Release 2 (OPM2.171019.012)</span><br><span class="line"></span><br><span class="line">E:\android\manifest&gt;</span><br></pre></td></tr></table></figure>
</li>
<li><p>再次查看default.xml文件的default标签</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;default revision&#x3D;&quot;refs&#x2F;tags&#x2F;android-8.1.0_r2&quot;</span><br><span class="line">         remote&#x3D;&quot;aosp&quot;</span><br><span class="line">         sync-j&#x3D;&quot;4&quot; &#x2F;&gt;</span><br></pre></td></tr></table></figure>
<p>此时你已经选择好你想要下载的源码版本了。就来准备开始下载吧。</p>
</li>
</ul>
<h1 id="编辑Python下载脚本"><a href="#编辑Python下载脚本" class="headerlink" title="编辑Python下载脚本"></a>编辑Python下载脚本</h1><ul>
<li>创建一个文本文档，然后编辑如下代码，保存。<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">import xml.dom.minidom</span><br><span class="line">import os</span><br><span class="line">from subprocess import call</span><br><span class="line"></span><br><span class="line"># downloaded source path</span><br><span class="line">#源码根目录，android-8.1.0_r2可以自定义。</span><br><span class="line">rootdir &#x3D; &quot;E:&#x2F;android&#x2F;android-8.1.0_r2&quot;</span><br><span class="line"></span><br><span class="line"># git program path</span><br><span class="line">#GIT 可执行文件路径</span><br><span class="line">git &#x3D; &quot;D:&#x2F;Program Files&#x2F;Git&#x2F;bin&#x2F;git.exe&quot;</span><br><span class="line"></span><br><span class="line">#将要解析的文件</span><br><span class="line">dom &#x3D; xml.dom.minidom.parse(&quot;E:&#x2F;android&#x2F;manifest&#x2F;default.xml&quot;)</span><br><span class="line">root &#x3D; dom.documentElement</span><br><span class="line"></span><br><span class="line">#GIT命令前缀</span><br><span class="line">prefix &#x3D; git + &quot; clone https:&#x2F;&#x2F;aosp.tuna.tsinghua.edu.cn&#x2F;&quot;</span><br><span class="line">#GIT命令后缀</span><br><span class="line">suffix &#x3D; &quot;.git&quot;</span><br><span class="line">#创建根目录</span><br><span class="line">if not os.path.exists(rootdir):</span><br><span class="line">    os.mkdir(rootdir)</span><br><span class="line">#遍历defualt.xml，执行Git命令克隆源码。</span><br><span class="line">for node in root.getElementsByTagName(&quot;project&quot;):</span><br><span class="line">    os.chdir(rootdir)</span><br><span class="line">    d &#x3D; node.getAttribute(&quot;path&quot;)</span><br><span class="line">    last &#x3D; d.rfind(&quot;&#x2F;&quot;)</span><br><span class="line">    if last !&#x3D; -1:</span><br><span class="line">        d &#x3D; rootdir + &quot;&#x2F;&quot; + d[:last]</span><br><span class="line">        if not os.path.exists(d):</span><br><span class="line">            os.makedirs(d)</span><br><span class="line">        os.chdir(d)</span><br><span class="line">    cmd &#x3D; prefix + node.getAttribute(&quot;name&quot;) + suffix</span><br><span class="line">    call(cmd)</span><br></pre></td></tr></table></figure>

</li>
</ul>
<h1 id="执行Python-开始下载源码。"><a href="#执行Python-开始下载源码。" class="headerlink" title="执行Python 开始下载源码。"></a>执行Python 开始下载源码。</h1><ul>
<li><p>打开Python IDLE<br><img src="http://upload-images.jianshu.io/upload_images/2093886-2a293e366bdcba76.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="TIM截图20180102191300.png"></p>
</li>
<li><p>打开刚刚编辑的代码文档<br><img src="http://upload-images.jianshu.io/upload_images/2093886-dcbfb890c573a27f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="TIM截图20180102192032.png"></p>
</li>
</ul>
<p><img src="http://upload-images.jianshu.io/upload_images/2093886-a856b025d87fedac.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="TIM截图20180102192255.png"></p>
<ul>
<li>执行代码<br><img src="http://upload-images.jianshu.io/upload_images/2093886-9aee698760fe6da6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="TIM截图20180102192543.png"></li>
</ul>
<p>此时将看到命令窗口在不断的下载文件。就算大功告成，等待下载结束即可。</p>

            </div>
        
        <footer class="article-footer">
        </footer>
    </div>
</article>


    
<nav id="article-nav">
    
        <a href="/2018/08/06/Android-ADB%E5%91%BD%E4%BB%A4%E5%AE%9E%E7%8E%B0-%E9%9A%90%E8%97%8F%E5%B9%B3%E6%9D%BF%E4%BB%BB%E5%8A%A1%E6%A0%8F/" id="article-nav-newer" class="article-nav-link-wrap">
            <strong class="article-nav-caption">上一篇</strong>
            <div class="article-nav-title">
                
                    Android-ADB命令实现-隐藏平板任务栏
                
            </div>
        </a>
    
    
        <a href="/2018/08/06/Centos7-JDK%E5%AE%89%E8%A3%85%EF%BC%88SunJDK-OpenJDK%EF%BC%89/" id="article-nav-older" class="article-nav-link-wrap">
            <strong class="article-nav-caption">下一篇</strong>
            <div class="article-nav-title">Centos7 JDK安装（SunJDK OpenJDK）</div>
        </a>
    
</nav>





    
    




<!-- baidu url auto push script -->
<script type="text/javascript">
    !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=window.location.href,o=document.referrer;if(!e.test(r)){var n="//api.share.baidu.com/s.gif";o?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var t=new Image;t.src=n}}(window);
</script>     
</section>
        </div>
        <footer id="footer">
    <div class="outer">
        <div id="footer-info" class="inner">
            <!-- 沈春平 &copy; 2020 
            <a rel="license noopener" href="http://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/80x15.png" /></a> -->
            <!-- <br>  -->
            &copy; 2020 
            Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>. Theme - <a href="https://github.com/zthxxx/hexo-theme-Wikitten" target="_blank" rel="noopener">wikitten</a>
            
                <br>
                <span id="busuanzi_container_site_pv"><i class="fa fa-eye"></i> <span id="busuanzi_value_site_pv"></span></span>
                &nbsp;|&nbsp;
                <span id="busuanzi_container_site_pv"><i class="fa fa-user"></i> <span id="busuanzi_value_site_uv"></span></span>
            
        </div>
    </div>
</footer>

        

    
        
<script src="/libs/lightgallery/js/lightgallery.min.js"></script>

        
<script src="/libs/lightgallery/js/lg-thumbnail.min.js"></script>

        
<script src="/libs/lightgallery/js/lg-pager.min.js"></script>

        
<script src="/libs/lightgallery/js/lg-autoplay.min.js"></script>

        
<script src="/libs/lightgallery/js/lg-fullscreen.min.js"></script>

        
<script src="/libs/lightgallery/js/lg-zoom.min.js"></script>

        
<script src="/libs/lightgallery/js/lg-hash.min.js"></script>

        
<script src="/libs/lightgallery/js/lg-share.min.js"></script>

        
<script src="/libs/lightgallery/js/lg-video.min.js"></script>

    
    
        
<script src="/libs/justified-gallery/jquery.justifiedGallery.min.js"></script>

    
    
        <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ["$","$"], ["\\(","\\)"] ],
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
            processEscapes: true,
            TeX: {
                equationNumbers: {
                  autoNumber: 'AMS'
                }
            }
        }
    });
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax();
        for (var i = 0; i < all.length; ++i)
            all[i].SourceElement().parentNode.className += ' has-jax';
    });
</script>
<script async src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    



<!-- Custom Scripts -->

<script src="/js/main.js"></script>


    </div>
</body>
</html>